﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Snippet_saver
{
    public partial class createfile : Form
    {
        public createfile()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (File.Exists("./data/" + textBox1.Text))
            {
                MessageBox.Show("File exists already, please use that file.");
            }
            else
            {
                try
                {

                    FileStream fstream = File.Create("./data/" + textBox1.Text);
                    fstream.Close();
                    MessageBox.Show("File succesfully created, refresh list to see it.");

                    Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error occured.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

    }
}
